<?php
/**
 * Created by PhpStorm.
 * User: songs
 * Date: 2019/10/12
 * Time: 10:13
 */

namespace App\admin\TableView;


use App\admin\TableView\BaseClass\BaseViewList;
use App\Jobs\Fun;
use App\Models\Admin\ApilistModel;
use App\Models\Admin\CategoryModel;
use App\Models\Admin\CompanyModel;
use App\Models\Admin\OrderBaleModel;
use App\Models\Admin\OrderTempModel;
use App\Models\Admin\UserModel;
use App\Models\AreaModel;
use App\Models\Main\AdModel;
use App\Models\User\UsergongchangModel;
use App\Models\User\UserGongsiModel;
use Faker\Provider\Company;

class OrdersTempListView extends BaseViewList
{

    public function get_model()
    {

        return new OrderTempModel();
    }

    public $show_add = false; ///显示添加按钮
    /**
     * 是否显示删除按钮
     */
    public $show_delete = false;
    public $topTitle = '抢单列表';
    public $PageSize = 10;

    public $breadcrumb = '<li><a href="/mcadmin">Home</a></li>
        <li><a href="javascript:;">抢单列表</a></li>
        ';

    public $html = '';


    //  public $show_add = false; ///显示添加按钮

    /**
     * 获取表格的唯一名字
     */
    public function getName()
    {
        return 'OrderTempModel';
    }


    /**
     * 需要继承,然后定义每行需要显示的数据格式
     */
    public function Labels()
    {
        return array(
            //   BaseViewList::Button_checkbox=>[],
            'id' => 50,
            'bale' => 40,
            'cid' => 150,
            'fid' => 150,
            'out_trade_no' => 150,
            'status' => 150,
            'created_at' => 150,
            'ip' => 150,
            'bond_money' => 150,
            'play_status' => 80,
            BaseViewList::Button_control => [
              //  BaseViewList::Button_Edit,
            //     BaseViewList::Button_Delete
            ]
        );
    }

    /**
     * 对话框中的各个字段
     */
    public function dialog()
    {
        return array(

        );
    }

    /**
     * 方便继承,多一层过滤
     */
    public function ModelTohtml($key, $model)
    {
        if($key==='created_at'){
            return Fun::date($model->$key);
        }
        if($key=='fid'){
            return UsergongchangModel::getCom_name($model->$key);
        }
        if($key=='cid'){
            return UserGongsiModel::getCom_name($model->$key);
        }
        if($key=='status'){
            return OrderTempModel::getstatus($model->$key);
        }
        if($key=='play_status'){
            return OrderTempModel::get_play_status($model->$key);
        }
        return parent::ModelTohtml($key, $model);
    }

    /**
     * 返回查询的条件
     */
    public function find()
    {
        $find = $this->get_model()->where([
        ]);
        $id=$_GET['id']??'';
        if($id!==''){
            $find->where([
                'bale'=>$id
            ]);
        }
        $fid=$_GET['fid']??'';
        if($fid!==''){
            $find->where([
                'fid'=>$fid
            ]);
        }

        $find->orderBy('id', 'DESC');
        return $find;
    }


    /**
     * 顶部的选择区,参数,如果为空,则不显示选择器
     */
    public function getselectAttr()
    {

        /// self::dropDownList,
        $where = [

        ];
        return $where;
    }

}
